/**********************************************************
Leo Engine - v0.1

file: leo_game.cpp
creation date: 17/04/2009
**********************************************************/
#include "Game.h"
#include "os/Graphics/Graphics.h"

leo::Game::Game(HINSTANCE hins): instance(hins) {}



bool leo::Game::Init()
{
	timer = new Timer;

	wnd= new Window(instance);
	graph= new Graphics();

	if(!wnd->createWindow(800,600))
	{
		return false;
	}

	if(!graph->InitDX(wnd))

	{
		return false;
	}
//---inits----
	graph->Init();
	
	timer->firstMeasure();
	input = new DirectInput(instance, wnd->getHwnd());
	if(!input->Init())
	{
		return false;
	}
	//collision = new CheckCollision;
//------------
	this->onInit();

	return true;
}

bool leo::Game::Update()
{
	
	timer->measure();
	input->Update();
	this->onUpdate();
	return true;
}
bool leo::Game::Draw()
{
	
	graph->Clear();

	graph->BeginScene();

	this->onDraw();
    
	graph->EndScene();

	graph->Present();
	
	return true;
}


bool leo::Game::DeInit()
{
	input->Deinit();
	this->onDeInit();
	return true;
}
